//
//  YFHomeCourseTableViewCell.m
//  YFListenStock
//
//  Created by ChinaRainbow-iOS on 2019/3/10.
//  Copyright © 2019 ChinaRainbow-iOS. All rights reserved.
//

#import "YFHomeCourseTableViewCell.h"

@implementation YFHomeCourseTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = HexColor(0xECF0F5);
    // Initialization code
}
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self = [[NSBundle mainBundle]loadNibNamed:@"YFHomeCourseTableViewCell" owner:self options:nil].lastObject;
    }
    return self;
}
-(void)setModel:(YFCourseModel *)model
{
    _model = model;
    [self.yfHeadImageV sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:SETIMAGE(@"logo")];
    self.yfTitleLabel.text = [NSString stringWithFormat:@"%@ | %@",model.user.name,model.title];
    self.yfContentLabel.text = model.describe;
    self.yfOrderNumberLabel.text = [NSString stringWithFormat:@"%@人已订阅",model.subscribe_countString];
    if ([model.purchasable_type intValue] == 0) {// 免费
        [self.yfPeriodBtn setTitle:@"免费" forState:0];
    }else{
        [self.yfPeriodBtn setTitle:@"付费" forState:0];
    }
    if (model.latest_section) {
        self.yfPeriodBtn.hidden = NO;
        self.yfSubTitleLabel.hidden = NO;
        self.yfArrawImageV.hidden = NO;
        self.yfMiddleLineLabel.hidden = NO;
        self.yfSubTitleLabel.text = model.latest_section.title;
        [self.yfPeriodBtn setTitle:[NSString stringWithFormat:@"%@期",model.latest_section.weight] forState:0];
    }else{
        self.yfPeriodBtn.hidden = YES;
        self.yfSubTitleLabel.hidden = YES;
        self.yfArrawImageV.hidden = YES;
        self.yfMiddleLineLabel.hidden = YES;
    }
    
}
@end
